﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace MidSoft.Web.Model_T_PET_PETINFO
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				#warning 代码生成提示：显示页面,请检查确认该语句是否正确
				ShowInfo();
			}
		}
			
	private void ShowInfo()
	{
		MidSoft.BLL.BLL_T_PET_PETINFO bll=new MidSoft.BLL.BLL_T_PET_PETINFO();
		MidSoft.Model.Model_T_PET_PETINFO model=bll.GetModel();
		this.txtPET_PETINFO_ID.Text=model.PET_PETINFO_ID;
		this.txtPERMISSION_NO.Text=model.PERMISSION_NO;
		this.txtAREA_GRADE.Text=model.AREA_GRADE.ToString();
		this.txtRFID_DATE.Text=model.RFID_DATE.ToString();
		this.txtUSE_TYPE.Text=model.USE_TYPE;
		this.txtCOLOR_ID.Text=model.COLOR_ID;
		this.txtBREED_ID.Text=model.BREED_ID;
		this.txtFATHER_BREED.Text=model.FATHER_BREED.ToString();
		this.txtMOTHER_BREED.Text=model.MOTHER_BREED.ToString();
		this.txtOWNER_ID.Text=model.OWNER_ID;
		this.txtAREA_ID.Text=model.AREA_ID;
		this.txtCERT_ORG_ID.Text=model.CERT_ORG_ID;
		this.txtBIRTHDAY.Text=model.BIRTHDAY.ToString();
		this.txtCERT_DATE.Text=model.CERT_DATE.ToString();
		this.txtCHARACTER.Text=model.CHARACTER;
		this.txtHEIGHT.Text=model.HEIGHT.ToString();
		this.txtIMMUNITY_NO.Text=model.IMMUNITY_NO;
		this.txtIMPORT_ADDRESS.Text=model.IMPORT_ADDRESS;
		this.txtNAME.Text=model.NAME;
		this.txtNOTE.Text=model.NOTE;
		this.txtOWNER_TYPE.Text=model.OWNER_TYPE;
		this.txtPET_NO.Text=model.PET_NO;
		this.txtREG_ORG_ID.Text=model.REG_ORG_ID;
		this.txtRFID.Text=model.RFID;
		this.txtSEX.Text=model.SEX;
		this.txtSTATE.Text=model.STATE;
		this.txtTYPE.Text=model.TYPE.ToString();
		this.txtWEIGHT.Text=model.WEIGHT.ToString();
		this.txtREGISTER_NO.Text=model.REGISTER_NO;
		this.txtADDRESS.Text=model.ADDRESS;
		this.txtCREATE_TIME.Text=model.CREATE_TIME.ToString();
		this.txtCREATOR_ID.Text=model.CREATOR_ID;
		this.txtUPDATE_TIME.Text=model.UPDATE_TIME.ToString();
		this.txtUPDATOR_ID.Text=model.UPDATOR_ID;
		this.txtPETIMAGE_ID.Text=model.PETIMAGE_ID;
		this.txtREGISTER_ID.Text=model.REGISTER_ID;
		this.txtISLOGOUT.Text=model.ISLOGOUT.ToString();
		this.txtPOLICE_STATION.Text=model.POLICE_STATION;
		this.txtPETAGE.Text=model.PETAGE.ToString();
		this.txtID.Text=model.ID.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtPET_PETINFO_ID.Text.Trim().Length==0)
			{
				strErr+="ID不能为空！\\n";	
			}
			if(this.txtPERMISSION_NO.Text.Trim().Length==0)
			{
				strErr+="许可号。不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtAREA_GRADE.Text))
			{
				strErr+="区域等级。格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtRFID_DATE.Text))
			{
				strErr+="RFID日期。格式错误！\\n";	
			}
			if(this.txtUSE_TYPE.Text.Trim().Length==0)
			{
				strErr+="用户类型。不能为空！\\n";	
			}
			if(this.txtCOLOR_ID.Text.Trim().Length==0)
			{
				strErr+="颜色ID。不能为空！\\n";	
			}
			if(this.txtBREED_ID.Text.Trim().Length==0)
			{
				strErr+="品种ID。不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtFATHER_BREED.Text))
			{
				strErr+="父亲品种。格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtMOTHER_BREED.Text))
			{
				strErr+="母亲品种。格式错误！\\n";	
			}
			if(this.txtOWNER_ID.Text.Trim().Length==0)
			{
				strErr+="属主ID。不能为空！\\n";	
			}
			if(this.txtAREA_ID.Text.Trim().Length==0)
			{
				strErr+="区域ID。不能为空！\\n";	
			}
			if(this.txtCERT_ORG_ID.Text.Trim().Length==0)
			{
				strErr+="证书ID。不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtBIRTHDAY.Text))
			{
				strErr+="生日。格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCERT_DATE.Text))
			{
				strErr+="发证日期。格式错误！\\n";	
			}
			if(this.txtCHARACTER.Text.Trim().Length==0)
			{
				strErr+="特征。不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtHEIGHT.Text))
			{
				strErr+="高度。格式错误！\\n";	
			}
			if(this.txtIMMUNITY_NO.Text.Trim().Length==0)
			{
				strErr+="免疫号。不能为空！\\n";	
			}
			if(this.txtIMPORT_ADDRESS.Text.Trim().Length==0)
			{
				strErr+="引入地址。不能为空！\\n";	
			}
			if(this.txtNAME.Text.Trim().Length==0)
			{
				strErr+="名字。不能为空！\\n";	
			}
			if(this.txtNOTE.Text.Trim().Length==0)
			{
				strErr+="备注。不能为空！\\n";	
			}
			if(this.txtOWNER_TYPE.Text.Trim().Length==0)
			{
				strErr+="属主类型。不能为空！\\n";	
			}
			if(this.txtPET_NO.Text.Trim().Length==0)
			{
				strErr+="宠物号。不能为空！\\n";	
			}
			if(this.txtREG_ORG_ID.Text.Trim().Length==0)
			{
				strErr+="注册机构ID。不能为空！\\n";	
			}
			if(this.txtRFID.Text.Trim().Length==0)
			{
				strErr+="RFID号。不能为空！\\n";	
			}
			if(this.txtSEX.Text.Trim().Length==0)
			{
				strErr+="性别。不能为空！\\n";	
			}
			if(this.txtSTATE.Text.Trim().Length==0)
			{
				strErr+="状态。不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtTYPE.Text))
			{
				strErr+="类型。格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtWEIGHT.Text))
			{
				strErr+="重量。格式错误！\\n";	
			}
			if(this.txtREGISTER_NO.Text.Trim().Length==0)
			{
				strErr+="受理号。不能为空！\\n";	
			}
			if(this.txtADDRESS.Text.Trim().Length==0)
			{
				strErr+="地址。不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCREATE_TIME.Text))
			{
				strErr+="创建时间。格式错误！\\n";	
			}
			if(this.txtCREATOR_ID.Text.Trim().Length==0)
			{
				strErr+="创建人。不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtUPDATE_TIME.Text))
			{
				strErr+="更新时间。格式错误！\\n";	
			}
			if(this.txtUPDATOR_ID.Text.Trim().Length==0)
			{
				strErr+="更新人。不能为空！\\n";	
			}
			if(this.txtPETIMAGE_ID.Text.Trim().Length==0)
			{
				strErr+="宠物头像ID。不能为空！\\n";	
			}
			if(this.txtREGISTER_ID.Text.Trim().Length==0)
			{
				strErr+="注册ID。不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtISLOGOUT.Text))
			{
				strErr+="注销。格式错误！\\n";	
			}
			if(this.txtPOLICE_STATION.Text.Trim().Length==0)
			{
				strErr+="派出所。不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtPETAGE.Text))
			{
				strErr+="年龄。格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtID.Text))
			{
				strErr+="原ID格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string PET_PETINFO_ID=this.txtPET_PETINFO_ID.Text;
			string PERMISSION_NO=this.txtPERMISSION_NO.Text;
			decimal AREA_GRADE=decimal.Parse(this.txtAREA_GRADE.Text);
			DateTime RFID_DATE=DateTime.Parse(this.txtRFID_DATE.Text);
			string USE_TYPE=this.txtUSE_TYPE.Text;
			string COLOR_ID=this.txtCOLOR_ID.Text;
			string BREED_ID=this.txtBREED_ID.Text;
			decimal FATHER_BREED=decimal.Parse(this.txtFATHER_BREED.Text);
			decimal MOTHER_BREED=decimal.Parse(this.txtMOTHER_BREED.Text);
			string OWNER_ID=this.txtOWNER_ID.Text;
			string AREA_ID=this.txtAREA_ID.Text;
			string CERT_ORG_ID=this.txtCERT_ORG_ID.Text;
			DateTime BIRTHDAY=DateTime.Parse(this.txtBIRTHDAY.Text);
			DateTime CERT_DATE=DateTime.Parse(this.txtCERT_DATE.Text);
			string CHARACTER=this.txtCHARACTER.Text;
			decimal HEIGHT=decimal.Parse(this.txtHEIGHT.Text);
			string IMMUNITY_NO=this.txtIMMUNITY_NO.Text;
			string IMPORT_ADDRESS=this.txtIMPORT_ADDRESS.Text;
			string NAME=this.txtNAME.Text;
			string NOTE=this.txtNOTE.Text;
			string OWNER_TYPE=this.txtOWNER_TYPE.Text;
			string PET_NO=this.txtPET_NO.Text;
			string REG_ORG_ID=this.txtREG_ORG_ID.Text;
			string RFID=this.txtRFID.Text;
			string SEX=this.txtSEX.Text;
			string STATE=this.txtSTATE.Text;
			decimal TYPE=decimal.Parse(this.txtTYPE.Text);
			decimal WEIGHT=decimal.Parse(this.txtWEIGHT.Text);
			string REGISTER_NO=this.txtREGISTER_NO.Text;
			string ADDRESS=this.txtADDRESS.Text;
			DateTime CREATE_TIME=DateTime.Parse(this.txtCREATE_TIME.Text);
			string CREATOR_ID=this.txtCREATOR_ID.Text;
			DateTime UPDATE_TIME=DateTime.Parse(this.txtUPDATE_TIME.Text);
			string UPDATOR_ID=this.txtUPDATOR_ID.Text;
			string PETIMAGE_ID=this.txtPETIMAGE_ID.Text;
			string REGISTER_ID=this.txtREGISTER_ID.Text;
			decimal ISLOGOUT=decimal.Parse(this.txtISLOGOUT.Text);
			string POLICE_STATION=this.txtPOLICE_STATION.Text;
			decimal PETAGE=decimal.Parse(this.txtPETAGE.Text);
			decimal ID=decimal.Parse(this.txtID.Text);


			MidSoft.Model.Model_T_PET_PETINFO model=new MidSoft.Model.Model_T_PET_PETINFO();
			model.PET_PETINFO_ID=PET_PETINFO_ID;
			model.PERMISSION_NO=PERMISSION_NO;
			model.AREA_GRADE=AREA_GRADE;
			model.RFID_DATE=RFID_DATE;
			model.USE_TYPE=USE_TYPE;
			model.COLOR_ID=COLOR_ID;
			model.BREED_ID=BREED_ID;
			model.FATHER_BREED=FATHER_BREED;
			model.MOTHER_BREED=MOTHER_BREED;
			model.OWNER_ID=OWNER_ID;
			model.AREA_ID=AREA_ID;
			model.CERT_ORG_ID=CERT_ORG_ID;
			model.BIRTHDAY=BIRTHDAY;
			model.CERT_DATE=CERT_DATE;
			model.CHARACTER=CHARACTER;
			model.HEIGHT=HEIGHT;
			model.IMMUNITY_NO=IMMUNITY_NO;
			model.IMPORT_ADDRESS=IMPORT_ADDRESS;
			model.NAME=NAME;
			model.NOTE=NOTE;
			model.OWNER_TYPE=OWNER_TYPE;
			model.PET_NO=PET_NO;
			model.REG_ORG_ID=REG_ORG_ID;
			model.RFID=RFID;
			model.SEX=SEX;
			model.STATE=STATE;
			model.TYPE=TYPE;
			model.WEIGHT=WEIGHT;
			model.REGISTER_NO=REGISTER_NO;
			model.ADDRESS=ADDRESS;
			model.CREATE_TIME=CREATE_TIME;
			model.CREATOR_ID=CREATOR_ID;
			model.UPDATE_TIME=UPDATE_TIME;
			model.UPDATOR_ID=UPDATOR_ID;
			model.PETIMAGE_ID=PETIMAGE_ID;
			model.REGISTER_ID=REGISTER_ID;
			model.ISLOGOUT=ISLOGOUT;
			model.POLICE_STATION=POLICE_STATION;
			model.PETAGE=PETAGE;
			model.ID=ID;

			MidSoft.BLL.BLL_T_PET_PETINFO bll=new MidSoft.BLL.BLL_T_PET_PETINFO();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
